package com.mask.im.business.controller.manage;


import com.mask.im.business.annotation.OptLog;
import com.mask.im.business.model.dto.ExceptionLogDTO;
import com.mask.im.business.model.vo.ConditionVO;
import com.mask.im.business.common.model.PageResult;
import com.mask.im.business.common.model.RestResponse;
import com.mask.im.business.service.SysExceptionLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

import static com.mask.im.business.common.constant.OptTypeConstant.DELETE;

/**
 * 异常日志查询
 *
 * @author jian
 */
@Api(tags = "异常日志模块")
@RestController
public class SysExceptionLogController {

    @Resource
    private SysExceptionLogService sysExceptionLogService;

    @ApiOperation("获取异常日志")
    @GetMapping("/admin/exception/logs")
    public RestResponse<PageResult<ExceptionLogDTO>> listExceptionLogs(ConditionVO conditionVO) {
        return RestResponse.ok(sysExceptionLogService.listExceptionLogs(conditionVO));
    }

    @OptLog(optType = DELETE)
    @ApiOperation(value = "删除异常日志")
    @DeleteMapping("/admin/exception/logs")
    public RestResponse<?> deleteExceptionLogs(@RequestBody List<Integer> exceptionLogIds) {
        sysExceptionLogService.removeByIds(exceptionLogIds);
        return RestResponse.ok();
    }

}
